class Solution:
    def reversePrefix(self, word: str, ch: str) -> str:
        if ch in word:
            word = list(word)
            idx = word.index(ch)
            word[:idx + 1] = word[:idx + 1][::-1]
            word = "".join(word)
        return word


if __name__ == "__main__":
    print(Solution().reversePrefix(word="abcdefd", ch="d"))
    print(Solution().reversePrefix(word="xyxzxe", ch="z"))
    print(Solution().reversePrefix(word="abcd", ch="z"))
